package com.soujiayi.view;

import com.soujiayi.activity.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;

public class NetworkUnavailableDialog extends AlertDialog{
	
	private Activity context;
	
	public NetworkUnavailableDialog(Context context, int theme) {
	    super(context, theme);
	    this.context = (Activity) context;
	}

	public NetworkUnavailableDialog(Context context) {
		super(context);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.network_unavailable_dialog);
	    Button comfirm = (Button) this.findViewById(R.id.dialog_confirm);
	    comfirm.setOnClickListener(new android.view.View.OnClickListener() {	
			@Override
			public void onClick(View v) {
				NetworkUnavailableDialog.this.cancel();
			}
		});
	    
    	WindowManager windowManager = context.getWindowManager();
    	Display display = windowManager.getDefaultDisplay();
    	WindowManager.LayoutParams lp = this.getWindow().getAttributes();
    	lp.width = (int)(display.getWidth() * 0.9);
    	//lp.height = (int)(display.getHeight() * 0.3);
    	//lp.alpha = 0.8f;
    	this.getWindow().setAttributes(lp);
	}
	
	
}